
package net.swa.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class UiInterceptor extends MethodFilterInterceptor
{
    private static final long serialVersionUID = -435231817099494168L;

    private final Logger log = Logger.getLogger(UiInterceptor.class);
    @Override
    protected String doIntercept(ActionInvocation action) throws Exception
    {
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpSession session = request.getSession();
        if (null == session)
        {
            return "outTimeError";
        }
        else
        {
            String u = (String) session.getAttribute("wxid");
            log.debug("微信端拦截器生效。。。wxid is "+u);
            if (StringUtils.isBlank(u))
            {
                return "outTimeError";
            }
            else
            {
                return action.invoke();
            }
        }
    }
}
